home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12289 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.6 KB

  1. Path: news.asiaonline.net!usenet
  2. From: samsona@asiaonline.net (Samson Lin)
  3. Newsgroups: comp.lang.c
  4. Subject: Can't Display PopUp Window
  5. Date: Sat, 30 Mar 1996 09:04:49 GMT
  6. Organization: Reader's Digest Far East
  7. Message-ID: <4jitak$pea@news.asiaonline.net>
  8. NNTP-Posting-Host: ip101.asiaonline.net
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Hi,
  12.  
  13. I am writing a Window C program.  I meet a problem in displaying popup
  14.  
  15. window.
  16.  
  17. The program is a quite simple program.  It is a phone book to record
  18. name, address, & tel. no.  It has a menu bar with 2 options:
  19.  
  20.    ABOUTMENU MENU
  21.    {
  22.       MENUITEM "Load/Save PhoneBk    ", CM_LOAD_SAVE
  23.       MENUITEM "Exit", CM_EXIT
  24.    }
  25.  
  26. CM_EXIT is for program exit while CM_LOAD_SAVE is for displaying
  27. another window for file loading & saving.  The popup window is
  28. designed like the popup window after you press "Save as" command in
  29. Word or Excel.
  30.  
  31. The followings are the codes for calling the popup window dialog &
  32. exit under WM_COMMAND, switch statements; as well as the LOAD/SAVE
  33. dialog function "LoadSaveDlgProc":
  34.  
  35.   case CM_LOAD_SAVE:
  36.   {
  37.       FARPROC LoadSaveDlg = 
  38.            MakeProcInstance((FARPROC)LoadSaveDlgProc, hInstance);
  39.  
  40.     if (hInstance == NULL)
  41.         MessageBox(hwnd, "MakeProcInstance Failed",    
  42.                    "DEBUG CM_LOAD_SAVE", MB_OK|MB_ICONEXCLAMATION);
  43.     else
  44.         MessageBox(hwnd, "MakeProcInstance Successful", 
  45.                    "DEBUG CM_LOAD_SAVE", MB_OK|MB_ICONEXCLAMATION);
  46.  
  47.     DialogBox(hInstance, "SAVEDLG", hwnd, (DLGPROC)LoadSaveDlg);
  48.  
  49.     MessageBox(hwnd, "End of LOAD/SAVE DialogBox execution",
  50.                "DEBUG CM_LOAD_SAVE", MB_OK|MB_ICONEXCLAMATION);
  51.   
  52.     FreeProcInstance(LoadSaveDlg);
  53.   }
  54.   break;
  55.  
  56.   case CM_EXIT:
  57.   {
  58.     DestroyWindow(hwnd);
  59.   }
  60.   break;
  61.   .......
  62.  
  63. //-------------------------------------------------------------------
  64.   BOOL CALLBACK LoadSaveDlgProc(HWND hDlg, WORD Message,
  65.                 WPARAM wParam, LPARAM lParam)
  66.   {
  67.     .......
  68.   }
  69.  
  70. During the testing period, everything functioned smoothly.  I could
  71. display the LOAD/SAVE popup window by pressing MENUITEM "Load/Save
  72. PhoneBk" & exit the program normally by pressing MENUITEM "Exit".  The
  73. testing was done during I was in the Borland C++ 4.5 environment.
  74.  
  75. After the testing, I quitted Borland environment, open File Manager,
  76. clicked the phone book program line to have it executed.  All things
  77. got normal results.
  78.  
  79. Immediately, I quitted Windows to dos, & then enter Windows once
  80. again.  I opened File Manager & executed the same program.  The
  81. program still ran BUT when I clicked the LOAD/SAVE menuitem, the
  82. LOAD/SAVE popup window didn't appear!  The EXIT menuitem still worked
  83. instead.
  84.  
  85. So I added several MessageBox statements inside the "CM_LOAD_SAVE"
  86. module and test the program once again.  I quitted Window and entered
  87. once again, repeated the same things.  All messages were displayed
  88. before and after the following statement (shown in the source code 
  89. above, which calls the LOAD/SAVE dialog),
  90.  
  91.      DialogBox(hInstance, "SAVEDLG", hwnd, (DLGPROC)LoadSaveDlg);
  92.  
  93. but the DialogBox statement didn't execute, i.e. LoadSaveDlg not
  94. called.
  95.  
  96. If I repeat the following steps, I can always wake up the LOAD/SAVE 
  97. popup window :
  98.  
  99.    (1) Run Borland C++ IDE
  100.    (2) Run phone book program
  101.    
  102.                OR
  103.  
  104.    (1) Run Borland C++ IDE
  105.    (2) Quit Borland C++ IDE
  106.    (3) Run phone book program
  107.  
  108. If I don't run Borland C++ beforehand, the program still works but I 
  109. can't see the LOAD/SAVE popup window when I click the LOAD/SAVE menu
  110. item.  
  111.  
  112. Why the above case happens?  My pc configuration is Pentium 100,
  113. 8MB ram, Chinese Win v3.1 with Win32s.
  114.  
  115. Samson
  116. Reader's Digest Asso. Far East
  117. (samsona@asiaonline.net)
  118.  
  119.